package com.xl.ui_demo_widget;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.TextView;

public class TextViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_textview);

        TextView tvDemo = findViewById(R.id.tv_demo);

        tvDemo.setText("测试");
        tvDemo.setWidth(256);
        tvDemo.setHeight(256);
        tvDemo.setBackgroundColor(Color.GREEN);
        tvDemo.setTextColor(Color.BLUE);
        tvDemo.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
        tvDemo.setTypeface(Typeface.DEFAULT_BOLD);
        tvDemo.setScaleX(1.5f);
        tvDemo.setScaleY(1.5f);
        tvDemo.setBackgroundResource(R.drawable.ic_launcher_background);
        tvDemo.setGravity(Gravity.END);
        tvDemo.setPadding(10,30,10,0);
    }
}